/**
 * 
 */
package com.nsoft.server.serviceImpl;

import java.util.Date;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.nsoft.server.register.beans.GcHeader;
import com.nsoft.server.service.dao.AccountDao;
import com.nsoft.server.service.dao.GCDao;
import com.nsoft.server.service.dao.PartyDao;
import com.nsoft.server.service.main.GCService;

/**
 * @author venkat
 * 
 */
public class GCServiceImpl implements GCService {

	public GCDao gcdao;
	
	public GCDao getGcdao() {
		return gcdao;
	}

	public void setGcdao(GCDao gcdao) {
		this.gcdao = gcdao;
	}

	public AccountDao accountDao;

	public AccountDao getAccountDao() {
		return accountDao;
	}

	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}

	public PartyDao partyDao;

	public PartyDao getPartyDao() {
		return partyDao;
	}

	public void setPartyDao(PartyDao partyDao) {
		this.partyDao = partyDao;
	}

	@Transactional
	public GcHeader saveGc(GcHeader header) {
		header.setGchCharGcno("1444");
		header.setGchDateDispatched(new Date());
		header.setGchDateDelivered(new Date());
		header.setGchCharConsignoraddress("dzhd");
		header.setGchCharConsigneeaddress("adzhd");
		header.setTransportPartyMaster(partyDao.findById(new Integer(1), false));
		header.setConsigneePartyMaster(partyDao.findById(new Integer(1), false));
		header.setConsignorPartyMaster(partyDao.findById(new Integer(1), false));
		return gcdao.makePersistent(header);
	}

	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public GcHeader getGC(Long id) {
		return gcdao.findById(new Integer(id.intValue()), false);
	}
}
